package com.example.multipledatasourcesdemo.datasource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * This class is used for ...
 */

public class DynamicDataSourceContextHolder {

    private static final Logger log = LoggerFactory.getLogger(DynamicDataSourceContextHolder.class);
    private static final ThreadLocal<String> contextHolder = new ThreadLocal<String>();

    public static void setDataSourceType(String dataSourceType) {
        log.info("-----------------------> 切换数据源类型为：【{}】", dataSourceType);
        contextHolder.set(dataSourceType);
    }

    public static String getDataSourceType() {
        return contextHolder.get();
    }

    public static void clearDataSourceType() {
        contextHolder.remove();
    }

}